﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Alos.Entity;
using Alos.IRepository;
using PetaPoco;

namespace Alos.Repository
{
    public class RePutQuestionRepository : BaseRepository<RePutQuestion>, IRePutQuestionRepository
    {
        /// <summary>
        ///添加学生课堂问答
        /// </summary>
        /// <param name="RePutQuestion"></param>
        /// <returns></returns>
        public bool CreateRePutQuestion(RePutQuestion RePutQuestion)
        {
            return Convert.ToInt32( RePutQuestion.Insert())>0;
        }
        /// <summary>
        ///修改学生课堂问答
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public bool UpdateRePutQuestion(int  Id)
        {
            var sql = Sql.Builder.Append("UPDATE RePutQuestion SET IsEnd=1 WHERE ID=@1", Id);
            return DBContext.Execute(sql) > 0;
        }
        /// <summary>
        ///根据老师ID和备课ID获取学生课堂问答
        /// </summary>
        /// <param name="RePutQuestion"></param>
        /// <returns></returns>
        public IEnumerable<dynamic> getRePutQuestion(int TeacherID, int LessionID)
        {
            var sql = Sql.Builder.Append("select * from RePutQuestion where TeacherID=@0 and LessionID=@1", TeacherID,LessionID);
            return DBContext.Query<RePutQuestion>(sql);
        }
    }
}
